$currentDir = Get-Location
$dir = $env:windir + "\system32\inetsrv"

Set-Location $dir
$apps = .\appcmd.exe list config /section:system.webServer/fastCgi /xml

$found = $FALSE;

$phpXml = [xml] $apps;
$applicationNodes = $phpXml.SelectNodes("//application[@fullPath[contains(.,'php-cgi.exe')]]");
$count = [int] $applicationNodes.Count;

if ($count -gt 0)
{
    $phpExe = [System.IO.Path]::GetFullPath($applicationNodes.Item(0).fullPath);    
    
    $results = & $phpexe -v | Out-String

	$phpExeVersion = $results.Split()[1].Replace('-','');
                
    if ($phpExeVersion -ne $null)
    {   
        [int[]]$version = $phpExeVersion.Split('.');

        if ($version[0] -gt 5 -OR ($version[0] -eq 5 -AND $version[1] -gt 3) -OR ($version[0] -eq 5 -AND $version[1] -eq 3 -AND $version[2] -ge 3) -OR ($version[0] -eq 5 -AND $version[1] -eq 3 -AND $version[2] -eq 3))
        {
            $found = $TRUE;
        }                 
    }    
}

Set-Location $currentDir
$found;

